package com.supermap.deviceinfo.service.impl;

import com.supermap.common.JSONUtil;
import com.supermap.deviceInfo.dao.StationDao;
import com.supermap.deviceInfo.entity.Deviceinfo;
import com.supermap.deviceInfo.entity.Station;
import com.supermap.deviceinfo.service.StationService;
import com.supermap.disaster.service.impl.DisasterServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:langhongshuai
 * @Description:站点业务逻辑层
 * @Date:18/5/14 下午6:10
 */
@Service
public class StationServiceImpl implements StationService {


    /**
     *使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(StationServiceImpl.class);


    @Resource
    private StationDao stationDao;

    @Override
    public JSONUtil getStationByDeviceIdAndDate(String deviceId, String date) {
        //初始化Json封装工具类
        JSONUtil jsonUtil = new JSONUtil();
        try {
            //获得所有的设备信息
            Station station = stationDao.getStationByDeviceIdAndDate(date,deviceId);

            //获得所有的设备信息后返回的json数据
            jsonUtil.setMsg("Get station success！");
            jsonUtil.setIsSuccess(true);
            jsonUtil.setCode(200);
            jsonUtil.setData(station);
        }catch (Exception e) {
            //捕捉数据库异常
            logger.error("StationServiceImpl=>getStationByDeviceIdAndDate=>DaoException:"+e.getMessage());
            jsonUtil.setMsg("Get station flase！");
            jsonUtil.setIsSuccess(false);
            jsonUtil.setCode(100);
        }
        return jsonUtil;
    }
}
